﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xss.Core;
using System.Xml.Linq;

namespace Xss.Configuration
{
    /// <summary>
    /// 配置信息解析通用接口
    /// </summary>
    public interface IConfigurationInterpreter
    {
        /// <summary>
        /// 解析资源
        /// </summary>
        void ResolveResource(params Xss.IO.IResource[] args);

        /// <summary>
        /// 创建对象上下文工厂
        /// </summary>
        /// <returns></returns>
        IContextFactory BuildContextFactory();
    }

    public abstract class XmlConfigurationInterpreter : IConfigurationInterpreter
    {
        public virtual void ResolveResource(params IO.IResource[] args)
        {
            foreach (var f in args)
            {
                ProcessXml(XDocument.Load(f.Stream));
            }
        }

        protected abstract void ProcessXml(XDocument doc);

        public abstract IContextFactory BuildContextFactory();
    }



}
